#include "EditorPageAreaManagerViewModel.h"
#include "EditorPageAreaManagerModel.h"
#include "Object/NewObject.h"

#include "Widgets/Splitable/EditorSplitableLayoutViewModel.h"

void REditorPageAreaManagerViewModel::BindModel(TSharedObjectPtr<REditorPageAreaManagerModel> InModel)
{
    Model = InModel;

    LayoutModel = NewObject<REditorSplitableLayoutViewModel>(this);
    LayoutModel->OnBindItemViewModel.BindLambda(
        [this](TSharedObjectPtr<RObject> ItemModel)
        {
            TSharedObjectPtr<REditorPageAreaModel> PageAreaModel = ItemModel;
            auto PageAreaViewModel = NewObject<REditorPageAreaViewModel>(this);
            PageAreaViewModel->BindModel(PageAreaModel);
            return PageAreaViewModel;
        }
    );
    LayoutModel->BindModel(Model->GetLayout());

}